package com.exchange.View;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.Interpolator;
import android.view.animation.TranslateAnimation;
import android.widget.LinearLayout;
import com.exchange.Controller.ExchangeDataService;
import com.exchange.View.a.d;
import java.util.ArrayList;

class t extends LinearLayout
{
  public static final int j = 0;
  public static final int k = 1;
  public static final int l = 2;
  public static final int m = 3;
  private static final String v = "Panel2";
  private float A;
  private float B;
  private a C;
  private b D;
  private Interpolator E;
  private GestureDetector F;
  private int G;
  private int H;
  private int I;
  private c J;
  private Animation.AnimationListener K;
  public boolean a;
  public boolean b;
  public View c;
  public View d;
  public Drawable e;
  public Drawable f;
  public int g;
  public int h;
  public View i;
  public boolean n;
  public boolean o;
  public Context p;
  public int q;
  View.OnTouchListener r;
  TranslateAnimation s;
  Runnable t;
  public ArrayList<Animation.AnimationListener> u;
  private int w;
  private int x;
  private boolean y;
  private float z;

  public t(Context paramContext, int paramInt, boolean paramBoolean, ExchangeDataService paramExchangeDataService)
  {
    super(paramContext);
    this.a = false;
    this.g = -1;
    this.h = -1;
    this.n = false;
    this.o = false;
    this.r = new g(this);
    this.t = new f(this);
    this.u = new ArrayList();
    this.K = new e(this);
    this.p = paramContext;
    this.n = paramBoolean;
    this.x = 1000;
    a(paramInt, paramContext);
    this.y = false;
    this.D = b.c;
    this.J = new c(this);
    this.F = new GestureDetector(this.J);
    this.F.setIsLongpressEnabled(false);
  }

  public t(Context paramContext, int paramInt1, boolean paramBoolean, ExchangeDataService paramExchangeDataService, int paramInt2)
  {
    this(paramContext, paramInt1, paramBoolean, paramExchangeDataService);
    this.q = paramInt2;
  }

  private float a(float paramFloat, int paramInt1, int paramInt2)
  {
    return Math.min(Math.max(paramFloat, paramInt1), paramInt2);
  }

  private void h()
  {
    if (!(this.n))
    {
      if ((!(this.b)) || (this.f == null))
        break label42;
      this.c.setBackgroundDrawable(this.f);
    }
    while (true)
    {
      do
      {
        this.a = false;
        g();
        label42: return;
      }
      while ((this.b) || (this.e == null));
      this.c.setBackgroundDrawable(this.e);
    }
  }

  public void a(int paramInt, Context paramContext)
  {
    int i1;
    this.w = paramInt;
    if ((this.w == 0) || (this.w == 1))
    {
      i1 = 1;
      this.I = i1;
      setOrientation(this.I);
      if (!(this.n))
        break label48;
    }
    while (true)
    {
      while (true)
      {
        label48: 
        do
          while (true)
          {
            return;
            i1 = 0;
          }
        while ((this.e != null) || (this.f != null));
        if (this.w != 1)
          break;
        this.e = paramContext.getResources().getDrawable(com.exchange.View.a.d.i(this.p));
        this.f = paramContext.getResources().getDrawable(com.exchange.View.a.d.a(this.p));
      }
      this.e = paramContext.getResources().getDrawable(com.exchange.View.a.d.b(this.p));
      this.f = paramContext.getResources().getDrawable(com.exchange.View.a.d.c(this.p));
    }
  }

  public void a(Interpolator paramInterpolator)
  {
    this.E = paramInterpolator;
  }

  public void a(a parama)
  {
    this.C = parama;
  }

  public void a(boolean paramBoolean1, boolean paramBoolean2)
  {
    int i2;
    int i1 = 0;
    if (paramBoolean1)
      i2 = 0;
    while (true)
    {
      this.b = i2;
      if (!(paramBoolean2))
        break;
      this.D = b.a;
      if (!(this.b))
        this.d.setVisibility(0);
      post(this.t);
      return;
      i2 = 1;
    }
    View localView = this.d;
    if (paramBoolean1);
    while (true)
    {
      while (true)
      {
        localView.setVisibility(i1);
        h();
      }
      i1 = 8;
    }
  }

  public boolean a()
  {
    int i1;
    if (this.D == b.e)
      i1 = 1;
    while (true)
    {
      return i1;
      i1 = 0;
    }
  }

  public View b()
  {
    return this.c;
  }

  public View c()
  {
    return this.d;
  }

  public boolean d()
  {
    int i1;
    if (this.d.getVisibility() == 0)
      i1 = 1;
    while (true)
    {
      return i1;
      i1 = 0;
    }
  }

  protected void dispatchDraw(Canvas paramCanvas)
  {
    if ((this.D == b.a) && (!(this.b)))
    {
      if (this.I != 1)
        break label101;
      int i1 = this.G;
      if ((this.w == 2) || (this.w == 0))
        i1 = -i1;
      if (this.I != 1)
        break label109;
      paramCanvas.translate(0F, i1);
    }
    while (true)
    {
      label101: int i2;
      while (true)
      {
        if ((this.D == b.d) || (this.D == b.e))
          paramCanvas.translate(this.z, this.A);
        super.dispatchDraw(paramCanvas);
        return;
        i2 = this.H;
      }
      label109: paramCanvas.translate(i2, 0F);
    }
  }

  public void e()
  {
    if (this.i != null)
      this.i.setVisibility(8);
  }

  public void f()
  {
    if (this.i != null)
    {
      this.i.setVisibility(0);
      AlphaAnimation localAlphaAnimation = new AlphaAnimation(0F, 1F);
      localAlphaAnimation.setDuration(300L);
      localAlphaAnimation.setRepeatCount(0);
      this.i.setAnimation(localAlphaAnimation);
      localAlphaAnimation.startNow();
      this.i.setOnClickListener(new d(this));
    }
  }

  public void g()
  {
    if (!(this.n))
    {
      this.c.setOnTouchListener(this.r);
      if (this.C != null)
      {
        if (!(d()))
          break label44;
        this.C.a(this, null);
      }
      while (true)
      {
        return;
        label44: this.C.a(this);
      }
    }
    if (d())
      if (this.C != null)
        this.C.a(this, this.c);
    while (true)
    {
      do
        while (true)
          this.c.setOnClickListener(new i(this));
      while (this.C == null);
      this.C.a(this);
    }
  }

  public void onFinishInflate()
  {
    super.onFinishInflate();
    removeView(this.c);
    removeView(this.d);
    if ((this.w == 0) || (this.w == 2))
    {
      addView(this.d);
      addView(this.c);
    }
    while (true)
    {
      if (this.f != null)
        this.c.setBackgroundDrawable(this.f);
      if (!(d()))
        this.d.setVisibility(8);
      return;
      addView(this.c);
      addView(this.d);
    }
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
    this.H = this.d.getWidth();
    this.G = this.d.getHeight();
  }

  public static abstract interface a
  {
    public abstract void a(t paramt);

    public abstract void a(t paramt, View paramView);
  }

  class c
  implements GestureDetector.OnGestureListener
  {
    float a;
    float b;

    public void a(, int paramInt2)
    {
      this.b = paramInt1;
      this.a = paramInt2;
    }

    public boolean onDown()
    {
      int i;
      int j;
      this.a = 0F;
      this.b = 0F;
      if (t.a(this.c) != t.b.c)
      {
        j = 0;
        return j;
      }
      t.a(this.c, t.b.a);
      t localt = this.c;
      if (this.c.d.getVisibility() == 0)
        i = 1;
      while (true)
      {
        while (true)
        {
          localt.b = i;
          if (!(this.c.b))
            this.c.d.setVisibility(0);
          j = 1;
        }
        i = 0;
      }
    }

    public boolean onFling(, MotionEvent paramMotionEvent2, float paramFloat1, float paramFloat2)
    {
      float f;
      t.a(this.c, t.b.e);
      t localt = this.c;
      if (t.b(this.c) == 1)
        f = paramFloat2;
      while (true)
      {
        t.c(localt, f);
        this.c.post(this.c.t);
        return true;
        f = paramFloat1;
      }
    }

    public void onLongPress()
    {
    }

    public boolean onScroll(, MotionEvent paramMotionEvent2, float paramFloat1, float paramFloat2)
    {
      float f1;
      float f2;
      t.a(this.c, t.b.d);
      if (t.b(this.c) == 1)
      {
        this.a -= paramFloat2;
        if (t.c(this.c) == 0)
        {
          f2 = t.a(this.c, this.a, -t.e(this.c), 0);
          f1 = 0F;
        }
      }
      while (true)
      {
        while (true)
        {
          while (true)
          {
            if ((f1 != t.k(this.c)) || (f2 != t.i(this.c)))
            {
              t.b(this.c, f1);
              t.a(this.c, f2);
              this.c.invalidate();
            }
            return true;
            f2 = t.a(this.c, this.a, 0, t.e(this.c));
            f1 = 0F;
          }
          this.b -= paramFloat1;
          if (t.c(this.c) != 2)
            break;
          f1 = t.a(this.c, this.b, -t.d(this.c), 0);
          f2 = 0F;
        }
        f1 = t.a(this.c, this.b, 0, t.d(this.c));
        f2 = 0F;
      }
    }

    public void onShowPress()
    {
    }

    public boolean onSingleTapUp()
    {
      this.c.post(this.c.t);
      return true;
    }
  }

  public static enum b
  {
    static
    {
      b[] arrayOfb = new b[5];
      arrayOfb[0] = a;
      arrayOfb[1] = b;
      arrayOfb[2] = c;
      arrayOfb[3] = d;
      arrayOfb[4] = e;
      f = arrayOfb;
    }
  }
}